﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace SemestralniPraceY35VAN
{
    class Special
    {
        /// <summary>
        /// Properties of the special.
        /// </summary>
        private Hashtable properties;

        /// <summary>
        /// 
        /// </summary>
        public string ID { get { if (properties.ContainsKey("id")) return (string)properties["id"]; else return null; } }

        /// <summary>
        /// 
        /// </summary>
        public string Type { get { if (properties.ContainsKey("type")) return (string)properties["type"]; else return null; } }

        /// <summary>
        /// 
        /// </summary>
        public string Kind { get { if (properties.ContainsKey("kind")) return (string)properties["kind"]; else return null; } }

        /// <summary>
        /// 
        /// </summary>
        public string Message { get { if (properties.ContainsKey("message")) return (string)properties["message"]; else return null; } }

        /// <summary>
        /// 
        /// </summary>
        public Venue Venue { get { if (properties.ContainsKey("venue")) return (Venue)properties["venue"]; else return null; } }

        /// <summary>
        /// Constructs an object representing a special.
        /// </summary>
        /// <param name="special">XML node with information about the special</param>
        public Special(XmlNode special)
        {
            properties = new Hashtable();

            if (special.Name == "special")
            {
                for (int i = 0; i < special.ChildNodes.Count; i++)
                {
                    switch (special.ChildNodes[i].Name)
                    {
                        case "venue":
                            properties.Add(special.ChildNodes[i].Name, new Venue(special.ChildNodes[i]));
                            break;
                        default:
                            properties.Add(special.ChildNodes[i].Name, special.ChildNodes[i].InnerText);
                            break;
                    }
                }
            }
            else
            {
                throw new IOException("Not Special!");
            }
        }
    }
}
